<?php

namespace Emergine\Libs
{
/**
   * lib.settings -- Emergine Settings Library
   * @version: 1.0
   * @author: Hleb Piatrou <h.piatrou@softteco.com>
   * @link: http://code.google.com/p/emergine/
   * @copyright: Copyright 2011-2012 Hleb Piatrou
   * @license: MIT License http://www.opensource.org/licenses/mit-license.php
   * @interface: Common Control Interface (CCI)
   */
   
/**
   * Additional libs inclusione
   * @CCI: Common Control Interface
   * @lib.spyc: Emergine YAML Library
   */

  include_once "./interfaces/CCI.php";
	include_once "./libraries/lib.spyc.php";

/* Using additional namespaces */

	use Emergine\Interfaces\Settings as SettingsInterface;	
	use Emergine\Libs\Spyc as Spyc;	

/**
   * Emergine Settings class
   * 
   * This class can be used to getting framework configurations
   * 
   * Example of usage:
   * <code>
   * Settings::FILE; // returns the path of ./settings.yaml file
   * Settings::DBOptions("datasourse"); // returns the type of database
   * </code>
   * @interface: Common Model Interface (CCI)
   */
	
	class Settings implements SettingsInterface
	{
		const FILE = "./settings.yaml";
		/**
		 * @access: public
		 * @param: none
		 * @return: object
		 */				
		public function ObjectContent()
		{
			$object = Spyc::YAMLLoad(Settings::FILE);
			return (object)$object;
		}
		/**
		 * @access: public
		 * @param: $option - name of configuration option
		 * @return: string
		 */

		public function DBOptions($option)
		{
			$database = (array)Settings::ObjectContent()->{"Database"};
			return $database[$option];
		}
		/**
		 * @access: public
		 * @param: $option - name of configuration option
		 * @return: string
		 */		
		public function Files($option)
		{
			$file = (array)Settings::ObjectContent()->{"Files"};
			return (string)$file[$option];
		}
	}
}
?>
